﻿Ext.define('ux.PromptField', {
	extend : 'Ext.Container',
	xtype : 'promptField',
	requires : [],
	config : {
		layout : {
			type : 'hbox'
		},
		value : '',
		maxValue : '',
		items : [{
					flex : 1
				}, {
					flex : 4,
					xtype : 'container',
					style : 'background-color:#F5F5F5;padding:3px;border-radius:5px;',
					layout : {
						type : 'hbox'
					},
					items : [{
								flex : 1.2,
								xtype : 'button',
								cls : 'x-msgbox-x-button-jian',
								listeners : {
									tap : function(button, e, eOpts) {
										if(Number(this.parent.getComponent('field-value').getValue())==1){
											
										}else{
											this.parent.getComponent('field-value').setValue(Number(Number(this.parent.getComponent('field-value').getValue())-1));
										}
										this.parent.parent.setValue(Number(this.parent.getComponent('field-value').getValue()));
									}
								}
							}, {
								flex : 1.6,
								xtype : 'textfield',
								itemId: 'field-value',
								style : 'margin:0px 5px;background-color:#F5F5F5;',
								clearIcon : false,
								readOnly : true,
								listeners : {
									painted : function() {
										this.setValue(this.parent.parent.getValue());
									}
								}
							}, {
								flex : 1.2,
								xtype : 'button',
								cls : 'x-msgbox-x-button-jia',
								listeners : {
									tap : function(button, e, eOpts) {
										if(Number(this.parent.parent.getMaxValue())>0 && Number(this.parent.getComponent('field-value').getValue()) >= Number(this.parent.parent.getMaxValue())){
											navigator.notification.alert('已达到最大购买量', null,'温馨提示', '确定');
											return;
										}
										this.parent.getComponent('field-value').setValue(Number(Number(this.parent.getComponent('field-value').getValue())+1));
										this.parent.parent.setValue(Number(this.parent.getComponent('field-value').getValue()));
									}
								}
							}]
				}, {
					flex : 1
				}]
	}
});